How to Rotate different data in days of the week in php [migrated]
Posted
by
shihon
on Programmers
See other posts from Programmers
or by shihon
Published on 2012-07-05T06:22:02Z
Indexed on
2012/07/05
9:22 UTC
Read the original article
Hit count: 295
php
I am working on a project in which i have to distribute different ad's per day, the ad's in form of array are:
$ad = array( 'attribute1_value' => "12",
'attribute2_value' => "xyz",
'attribute3_value' => 'http://example.com',
'attribute4_value' => 'data');
The logic i am using with switch case :
$day = date('w',time());
switch ($day) {
case '0':
if($day == '0') {
$count = 0;
echo $ad;
$count++;
}
else {
$count = 7;
echo $ad;
}
break;
case '1':
if($day == '1') {
$count = 1;
echo $ad;
$count++;
}
else {
$count = 8;
echo $ad;
}
break;
Problem is if i have ~15 ad's then i want to distribute ad/day, date('w') output's the present day but after day 7 i.e saturday, on sunday ad number 8 initiate. I have to implement this scenario using date function. Also i have to send ad's to those user who are not experience this ad before. I am not expert in php, as a beginner working in php/mysql. Kindly help me to improve this concept
© Programmers or respective owner